package com.terminee.dataaccess;

import java.util.List;
import java.util.Map;

import com.terminee.behaviors.DAOBehavior;

/**
 * Performs basic CRUD operations on a db. Also includes a method for executing custom
 * queries on a db. The daoBehavior attribute determines how in particular CRUD operations
 * are performed.
 * 
 * @author potlow
 *
 */
public class DatabaseDAO {

	protected DAOBehavior daoBehavior;

    public boolean performCreate(Object value) {
        return daoBehavior.create(value);
    }

    public Object performRead(Object value, List<String> properties) {
        return daoBehavior.read(value, properties);
    }

    public boolean performUpdate(Object value) {
        return daoBehavior.update(value);
    }

    public boolean performDelete(Object value) {
        return daoBehavior.delete(value);
    }

    public Object performCustom(String filter,
            String declareParameters, Map<String,Object> parameters,
            List<String> properties) {
        return daoBehavior.excute(filter, declareParameters, parameters, properties);
    }

    public DAOBehavior getDAOBehavior() {
        return daoBehavior;
    }

    public void setDAOBehavior(DAOBehavior daoBehavior) {
        this.daoBehavior = daoBehavior;
    }
}
